package org.sampleSpringFramework.mvc.render.impl;

import org.sampleSpringFramework.mvc.processor.RequestProcessorChain;
import org.sampleSpringFramework.mvc.render.ResultRender;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;

/**
 * 服务内部出现错误时使用的结果渲染器
 */
public class InternalErrorResultRender implements ResultRender {

	private String errorMsg;

	public InternalErrorResultRender(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	@Override
	public void render(RequestProcessorChain requestProcessorChain) throws Exception {
		int code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
		requestProcessorChain.getResponse().sendError(code,errorMsg);//返回状态码，异常信息
	}
}
